/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * CreateUserViewImple.java
 *
 * Created on 15/02/2010, 22:48:12
 */

package tpdisenio2009.mvp.display;

import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.ActionListener;
import java.awt.event.ItemListener;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JOptionPane;
import javax.swing.event.DocumentListener;
import javax.swing.text.BadLocationException;
import tpdisenio2009.Constants;
import tpdisenio2009.model.beans.City;
import tpdisenio2009.model.beans.Country;
import tpdisenio2009.model.beans.State;

/**
 *
 * @author DeuterioX
 */
public class CreateUserViewImpl extends javax.swing.JDialog implements CreateUserView {

    /** Creates new form CreateUserViewImple */
    public CreateUserViewImpl(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        getRootPane().setDefaultButton(jButtonSave);
        Dimension dim = this.getToolkit().getScreenSize();
        this.setLocation((dim.width - this.getWidth()) / 2,(dim.height - this.getHeight()) / 2);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanelPersonalData = new javax.swing.JPanel();
        jLabelLastName = new javax.swing.JLabel();
        jTextFieldLastName = new javax.swing.JTextField();
        jLabelFirstName = new javax.swing.JLabel();
        jTextFieldFirstName = new javax.swing.JTextField();
        jLabelGenre = new javax.swing.JLabel();
        jComboBoxGenre = new javax.swing.JComboBox();
        jLabelDocumentType = new javax.swing.JLabel();
        jComboBoxDocumentType = new javax.swing.JComboBox();
        jLabelDocument = new javax.swing.JLabel();
        jTextFieldDocument = new javax.swing.JFormattedTextField();
        jLabelBirthDate = new javax.swing.JLabel();
        jFormattedTextFieldBirthDate = new javax.swing.JFormattedTextField();
        jPanelAddress = new javax.swing.JPanel();
        jTextFieldStreet = new javax.swing.JTextField();
        jTextFieldDepartment = new javax.swing.JTextField();
        jComboBoxCountry = new javax.swing.JComboBox();
        jComboBoxState = new javax.swing.JComboBox();
        jComboBoxCity = new javax.swing.JComboBox();
        jLabelStreet = new javax.swing.JLabel();
        jLabelStreetNumber = new javax.swing.JLabel();
        jLabelDepartment = new javax.swing.JLabel();
        jLabelFloor = new javax.swing.JLabel();
        jLabelBlock = new javax.swing.JLabel();
        jLabelCountry = new javax.swing.JLabel();
        jLabelState = new javax.swing.JLabel();
        jLabelCity = new javax.swing.JLabel();
        jTextFieldStreetNumber = new javax.swing.JTextField();
        jTextFieldBlock = new javax.swing.JTextField();
        jTextFieldFloor = new javax.swing.JTextField();
        jPanelAditionalData = new javax.swing.JPanel();
        jLabelPassword = new javax.swing.JLabel();
        jLabelEmail = new javax.swing.JLabel();
        jTextFieldEmail = new javax.swing.JTextField();
        jTextFieldPassword = new javax.swing.JTextField();
        jLabelConfirmedPassword = new javax.swing.JLabel();
        jTextFieldConfirmedPassword = new javax.swing.JTextField();
        jButtonSave = new javax.swing.JButton();
        jButtonCancel = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setLocationByPlatform(true);
        setName("Form"); // NOI18N

        jPanelPersonalData.setBorder(javax.swing.BorderFactory.createTitledBorder("Datos Personales"));
        jPanelPersonalData.setName("jPanelPersonalData"); // NOI18N

        jLabelLastName.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(tpdisenio2009.Tpdisenio2009App.class).getContext().getResourceMap(CreateUserViewImpl.class);
        jLabelLastName.setText(resourceMap.getString("jLabelLastName.text")); // NOI18N
        jLabelLastName.setName("jLabelLastName"); // NOI18N

        jTextFieldLastName.setName("jTextFieldLastName"); // NOI18N
        jTextFieldLastName.setNextFocusableComponent(jTextFieldFirstName);

        jLabelFirstName.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabelFirstName.setText(resourceMap.getString("jLabelFirstName.text")); // NOI18N
        jLabelFirstName.setName("jLabelFirstName"); // NOI18N

        jTextFieldFirstName.setName("jTextFieldFirstName"); // NOI18N
        jTextFieldFirstName.setNextFocusableComponent(jComboBoxGenre);

        jLabelGenre.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabelGenre.setText(resourceMap.getString("jLabelGenre.text")); // NOI18N
        jLabelGenre.setMaximumSize(new java.awt.Dimension(70, 14));
        jLabelGenre.setMinimumSize(new java.awt.Dimension(70, 14));
        jLabelGenre.setName("jLabelGenre"); // NOI18N
        jLabelGenre.setPreferredSize(new java.awt.Dimension(70, 14));

        jComboBoxGenre.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        jComboBoxGenre.setName("jComboBoxGenre"); // NOI18N
        jComboBoxGenre.setNextFocusableComponent(jComboBoxDocumentType);

        jLabelDocumentType.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabelDocumentType.setText(resourceMap.getString("jLabelDocumentType.text")); // NOI18N
        jLabelDocumentType.setName("jLabelDocumentType"); // NOI18N

        jComboBoxDocumentType.setName("jComboBoxDocumentType"); // NOI18N
        jComboBoxDocumentType.setNextFocusableComponent(jTextFieldDocument);

        jLabelDocument.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabelDocument.setText(resourceMap.getString("jLabelDocument.text")); // NOI18N
        jLabelDocument.setName("jLabelDocument"); // NOI18N

        try {
            jTextFieldDocument.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("########")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        jTextFieldDocument.setText(resourceMap.getString("jTextFieldDocument.text")); // NOI18N
        jTextFieldDocument.setFocusLostBehavior(javax.swing.JFormattedTextField.COMMIT);
        jTextFieldDocument.setName("jTextFieldDocument"); // NOI18N
        jTextFieldDocument.setNextFocusableComponent(jFormattedTextFieldBirthDate);

        jLabelBirthDate.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabelBirthDate.setText(resourceMap.getString("jLabelBirthDate.text")); // NOI18N
        jLabelBirthDate.setName("jLabelBirthDate"); // NOI18N

        jFormattedTextFieldBirthDate.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.DateFormatter(new java.text.SimpleDateFormat("dd/MM/yyyy"))));
        jFormattedTextFieldBirthDate.setName("jFormattedTextFieldBirthDate"); // NOI18N
        jFormattedTextFieldBirthDate.setNextFocusableComponent(jTextFieldStreet);

        javax.swing.GroupLayout jPanelPersonalDataLayout = new javax.swing.GroupLayout(jPanelPersonalData);
        jPanelPersonalData.setLayout(jPanelPersonalDataLayout);
        jPanelPersonalDataLayout.setHorizontalGroup(
            jPanelPersonalDataLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelPersonalDataLayout.createSequentialGroup()
                .addGroup(jPanelPersonalDataLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jLabelGenre, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabelFirstName, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabelLastName, javax.swing.GroupLayout.DEFAULT_SIZE, 63, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelPersonalDataLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelPersonalDataLayout.createSequentialGroup()
                        .addComponent(jComboBoxGenre, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 165, Short.MAX_VALUE))
                    .addComponent(jTextFieldFirstName, javax.swing.GroupLayout.DEFAULT_SIZE, 240, Short.MAX_VALUE)
                    .addComponent(jTextFieldLastName, javax.swing.GroupLayout.DEFAULT_SIZE, 240, Short.MAX_VALUE))
                .addGap(10, 10, 10)
                .addGroup(jPanelPersonalDataLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(jLabelBirthDate, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabelDocument, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabelDocumentType, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelPersonalDataLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jComboBoxDocumentType, 0, 185, Short.MAX_VALUE)
                    .addComponent(jFormattedTextFieldBirthDate, javax.swing.GroupLayout.DEFAULT_SIZE, 185, Short.MAX_VALUE)
                    .addComponent(jTextFieldDocument, javax.swing.GroupLayout.DEFAULT_SIZE, 185, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanelPersonalDataLayout.setVerticalGroup(
            jPanelPersonalDataLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelPersonalDataLayout.createSequentialGroup()
                .addGap(0, 0, Short.MAX_VALUE)
                .addGroup(jPanelPersonalDataLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelPersonalDataLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabelLastName)
                        .addComponent(jTextFieldLastName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanelPersonalDataLayout.createSequentialGroup()
                        .addGroup(jPanelPersonalDataLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jComboBoxDocumentType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabelDocumentType))
                        .addGap(18, 18, 18)
                        .addGroup(jPanelPersonalDataLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabelFirstName)
                            .addComponent(jTextFieldFirstName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabelDocument)
                            .addComponent(jTextFieldDocument, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(jPanelPersonalDataLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jFormattedTextFieldBirthDate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabelGenre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jComboBoxGenre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabelBirthDate))))
                .addGap(14, 14, 14))
        );

        jPanelAddress.setBorder(javax.swing.BorderFactory.createTitledBorder("Domicilio"));
        jPanelAddress.setName("jPanelAddress"); // NOI18N

        jTextFieldStreet.setName("jTextFieldStreet"); // NOI18N
        jTextFieldStreet.setNextFocusableComponent(jTextFieldStreetNumber);

        jTextFieldDepartment.setEnabled(false);
        jTextFieldDepartment.setName("jTextFieldDepartment"); // NOI18N
        jTextFieldDepartment.setNextFocusableComponent(jTextFieldFloor);

        jComboBoxCountry.setName("jComboBoxCountry"); // NOI18N
        jComboBoxCountry.setNextFocusableComponent(jComboBoxState);

        jComboBoxState.setEnabled(false);
        jComboBoxState.setName("jComboBoxState"); // NOI18N
        jComboBoxState.setNextFocusableComponent(jComboBoxCity);

        jComboBoxCity.setEnabled(false);
        jComboBoxCity.setName("jComboBoxCity"); // NOI18N
        jComboBoxCity.setNextFocusableComponent(jTextFieldPassword);

        jLabelStreet.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabelStreet.setText(resourceMap.getString("jLabelStreet.text")); // NOI18N
        jLabelStreet.setName("jLabelStreet"); // NOI18N

        jLabelStreetNumber.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabelStreetNumber.setText(resourceMap.getString("jLabelStreetNumber.text")); // NOI18N
        jLabelStreetNumber.setName("jLabelStreetNumber"); // NOI18N

        jLabelDepartment.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabelDepartment.setText(resourceMap.getString("jLabelDepartment.text")); // NOI18N
        jLabelDepartment.setName("jLabelDepartment"); // NOI18N

        jLabelFloor.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabelFloor.setText(resourceMap.getString("jLabelFloor.text")); // NOI18N
        jLabelFloor.setName("jLabelFloor"); // NOI18N

        jLabelBlock.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabelBlock.setText(resourceMap.getString("jLabelBlock.text")); // NOI18N
        jLabelBlock.setMaximumSize(new java.awt.Dimension(70, 14));
        jLabelBlock.setMinimumSize(new java.awt.Dimension(70, 14));
        jLabelBlock.setName("jLabelBlock"); // NOI18N
        jLabelBlock.setPreferredSize(new java.awt.Dimension(70, 14));

        jLabelCountry.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabelCountry.setText(resourceMap.getString("jLabelCountry.text")); // NOI18N
        jLabelCountry.setName("jLabelCountry"); // NOI18N
        jLabelCountry.setPreferredSize(new java.awt.Dimension(96, 14));

        jLabelState.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabelState.setText(resourceMap.getString("jLabelState.text")); // NOI18N
        jLabelState.setName("jLabelState"); // NOI18N

        jLabelCity.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabelCity.setText(resourceMap.getString("jLabelCity.text")); // NOI18N
        jLabelCity.setName("jLabelCity"); // NOI18N

        jTextFieldStreetNumber.setText(resourceMap.getString("jTextFieldStreetNumber.text")); // NOI18N
        jTextFieldStreetNumber.setEnabled(false);
        jTextFieldStreetNumber.setName("jTextFieldStreetNumber"); // NOI18N
        jTextFieldStreetNumber.setNextFocusableComponent(jTextFieldDepartment);

        jTextFieldBlock.setText(resourceMap.getString("jTextFieldBlock.text")); // NOI18N
        jTextFieldBlock.setEnabled(false);
        jTextFieldBlock.setName("jTextFieldBlock"); // NOI18N
        jTextFieldBlock.setNextFocusableComponent(jComboBoxCountry);

        jTextFieldFloor.setText(resourceMap.getString("jTextFieldFloor.text")); // NOI18N
        jTextFieldFloor.setEnabled(false);
        jTextFieldFloor.setName("jTextFieldFloor"); // NOI18N
        jTextFieldFloor.setNextFocusableComponent(jTextFieldBlock);

        javax.swing.GroupLayout jPanelAddressLayout = new javax.swing.GroupLayout(jPanelAddress);
        jPanelAddress.setLayout(jPanelAddressLayout);
        jPanelAddressLayout.setHorizontalGroup(
            jPanelAddressLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelAddressLayout.createSequentialGroup()
                .addGroup(jPanelAddressLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jLabelBlock, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(jPanelAddressLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabelDepartment, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addComponent(jLabelStreet, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabelStreetNumber, javax.swing.GroupLayout.DEFAULT_SIZE, 67, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelAddressLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jTextFieldStreet, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 240, Short.MAX_VALUE)
                    .addGroup(jPanelAddressLayout.createSequentialGroup()
                        .addGroup(jPanelAddressLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jTextFieldDepartment, javax.swing.GroupLayout.DEFAULT_SIZE, 90, Short.MAX_VALUE)
                            .addComponent(jTextFieldStreetNumber, javax.swing.GroupLayout.DEFAULT_SIZE, 90, Short.MAX_VALUE)
                            .addComponent(jTextFieldBlock, javax.swing.GroupLayout.DEFAULT_SIZE, 90, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabelFloor, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTextFieldFloor, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanelAddressLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(jLabelCity, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabelState, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabelCountry, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 103, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelAddressLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jComboBoxState, javax.swing.GroupLayout.Alignment.LEADING, 0, 185, Short.MAX_VALUE)
                    .addComponent(jComboBoxCity, 0, 185, Short.MAX_VALUE)
                    .addComponent(jComboBoxCountry, 0, 185, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanelAddressLayout.setVerticalGroup(
            jPanelAddressLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelAddressLayout.createSequentialGroup()
                .addGroup(jPanelAddressLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelStreet)
                    .addComponent(jTextFieldStreet, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jComboBoxCountry, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabelCountry, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanelAddressLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelStreetNumber)
                    .addComponent(jComboBoxState, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabelFloor)
                    .addComponent(jLabelState)
                    .addComponent(jTextFieldStreetNumber, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTextFieldFloor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanelAddressLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextFieldDepartment, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabelDepartment)
                    .addComponent(jComboBoxCity, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabelCity))
                .addGap(18, 18, 18)
                .addGroup(jPanelAddressLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelBlock, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTextFieldBlock, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanelAditionalData.setBorder(javax.swing.BorderFactory.createTitledBorder("Datos Adicionales"));
        jPanelAditionalData.setName("jPanelAditionalData"); // NOI18N

        jLabelPassword.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabelPassword.setText(resourceMap.getString("jLabelPassword.text")); // NOI18N
        jLabelPassword.setMaximumSize(new java.awt.Dimension(70, 14));
        jLabelPassword.setMinimumSize(new java.awt.Dimension(70, 14));
        jLabelPassword.setName("jLabelPassword"); // NOI18N
        jLabelPassword.setPreferredSize(new java.awt.Dimension(70, 14));

        jLabelEmail.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabelEmail.setText(resourceMap.getString("jLabelEmail.text")); // NOI18N
        jLabelEmail.setName("jLabelEmail"); // NOI18N

        jTextFieldEmail.setName("jTextFieldEmail"); // NOI18N
        jTextFieldEmail.setNextFocusableComponent(jButtonSave);

        jTextFieldPassword.setName("jTextFieldPassword"); // NOI18N
        jTextFieldPassword.setNextFocusableComponent(jTextFieldConfirmedPassword);

        jLabelConfirmedPassword.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabelConfirmedPassword.setText(resourceMap.getString("jLabelConfirmedPassword.text")); // NOI18N
        jLabelConfirmedPassword.setName("jLabelConfirmedPassword"); // NOI18N

        jTextFieldConfirmedPassword.setName("jTextFieldConfirmedPassword"); // NOI18N
        jTextFieldConfirmedPassword.setNextFocusableComponent(jTextFieldEmail);

        javax.swing.GroupLayout jPanelAditionalDataLayout = new javax.swing.GroupLayout(jPanelAditionalData);
        jPanelAditionalData.setLayout(jPanelAditionalDataLayout);
        jPanelAditionalDataLayout.setHorizontalGroup(
            jPanelAditionalDataLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelAditionalDataLayout.createSequentialGroup()
                .addGap(0, 0, 0)
                .addGroup(jPanelAditionalDataLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(jLabelEmail, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabelPassword, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelAditionalDataLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jTextFieldPassword, javax.swing.GroupLayout.DEFAULT_SIZE, 239, Short.MAX_VALUE)
                    .addComponent(jTextFieldEmail, javax.swing.GroupLayout.DEFAULT_SIZE, 239, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabelConfirmedPassword, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTextFieldConfirmedPassword, javax.swing.GroupLayout.DEFAULT_SIZE, 197, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanelAditionalDataLayout.setVerticalGroup(
            jPanelAditionalDataLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelAditionalDataLayout.createSequentialGroup()
                .addGroup(jPanelAditionalDataLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelPassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTextFieldPassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTextFieldConfirmedPassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabelConfirmedPassword))
                .addGap(18, 18, 18)
                .addGroup(jPanelAditionalDataLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelEmail)
                    .addComponent(jTextFieldEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jButtonSave.setText(resourceMap.getString("jButtonSave.text")); // NOI18N
        jButtonSave.setName("jButtonSave"); // NOI18N
        jButtonSave.setNextFocusableComponent(jButtonCancel);

        jButtonCancel.setText(resourceMap.getString("jButtonCancel.text")); // NOI18N
        jButtonCancel.setName("jButtonCancel"); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanelPersonalData, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanelAddress, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanelAditionalData, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(jButtonSave)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButtonCancel)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(18, 18, 18)
                .addComponent(jPanelPersonalData, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanelAddress, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanelAditionalData, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButtonCancel)
                    .addComponent(jButtonSave))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButtonCancel;
    private javax.swing.JButton jButtonSave;
    private javax.swing.JComboBox jComboBoxCity;
    private javax.swing.JComboBox jComboBoxCountry;
    private javax.swing.JComboBox jComboBoxDocumentType;
    private javax.swing.JComboBox jComboBoxGenre;
    private javax.swing.JComboBox jComboBoxState;
    private javax.swing.JFormattedTextField jFormattedTextFieldBirthDate;
    private javax.swing.JLabel jLabelBirthDate;
    private javax.swing.JLabel jLabelBlock;
    private javax.swing.JLabel jLabelCity;
    private javax.swing.JLabel jLabelConfirmedPassword;
    private javax.swing.JLabel jLabelCountry;
    private javax.swing.JLabel jLabelDepartment;
    private javax.swing.JLabel jLabelDocument;
    private javax.swing.JLabel jLabelDocumentType;
    private javax.swing.JLabel jLabelEmail;
    private javax.swing.JLabel jLabelFirstName;
    private javax.swing.JLabel jLabelFloor;
    private javax.swing.JLabel jLabelGenre;
    private javax.swing.JLabel jLabelLastName;
    private javax.swing.JLabel jLabelPassword;
    private javax.swing.JLabel jLabelState;
    private javax.swing.JLabel jLabelStreet;
    private javax.swing.JLabel jLabelStreetNumber;
    private javax.swing.JPanel jPanelAddress;
    private javax.swing.JPanel jPanelAditionalData;
    private javax.swing.JPanel jPanelPersonalData;
    private javax.swing.JTextField jTextFieldBlock;
    private javax.swing.JTextField jTextFieldConfirmedPassword;
    private javax.swing.JTextField jTextFieldDepartment;
    private javax.swing.JFormattedTextField jTextFieldDocument;
    private javax.swing.JTextField jTextFieldEmail;
    private javax.swing.JTextField jTextFieldFirstName;
    private javax.swing.JTextField jTextFieldFloor;
    private javax.swing.JTextField jTextFieldLastName;
    private javax.swing.JTextField jTextFieldPassword;
    private javax.swing.JTextField jTextFieldStreet;
    private javax.swing.JTextField jTextFieldStreetNumber;
    // End of variables declaration//GEN-END:variables

    public String getLastName() {
        return jTextFieldLastName.getText();
    }

    public String getFirstName() {
        return jTextFieldFirstName.getText();
    }

    public void setGenre( List<Character> genres ) {
        DefaultComboBoxModel model = new DefaultComboBoxModel();
        for ( Character genre : genres ) {
            model.addElement( genre );
        }
        jComboBoxGenre.setModel( model );
    }

    public Character getGenre() {
        DefaultComboBoxModel model = (DefaultComboBoxModel) jComboBoxGenre.getModel();
        return (Character) model.getSelectedItem();
    }

    public void setDocumentType( List<String> documentTypes ) {
        DefaultComboBoxModel model = new DefaultComboBoxModel();
        for ( String documentType : documentTypes ) {
            model.addElement( documentType );
        }
        jComboBoxDocumentType.setModel( model );
    }

    public String getDocumentType() {
        DefaultComboBoxModel model = (DefaultComboBoxModel) jComboBoxDocumentType.getModel();
        return (String) model.getSelectedItem();
    }

    public String getDocument() {
        return jTextFieldDocument.getText().trim();
    }

    public Date getBirthDate() {
        try {
            SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
            Date date = formatter.parse( jFormattedTextFieldBirthDate.getText() );
            return date;
        } catch ( ParseException ex ) {
            return null;
        }
    }

    public String getStreet() {
        if ( jTextFieldStreet.getText() == null )
            return "";
        else
            return jTextFieldStreet.getText();
    }

    public String getStreetNumber() {
        if ( jTextFieldStreetNumber.getText() == null )
            return "";
        else
            return  jTextFieldStreetNumber.getText();
    }

    public String getDepartment() {
        if ( jTextFieldDepartment.getText() == null )
            return "";
        else
            return jTextFieldDepartment.getText();
    }

    public String getBlock() {
        if ( jTextFieldBlock.getText() == null )
            return "";
        else
            return jTextFieldBlock.getText();
    }

    public String getFloor() {
        if ( jTextFieldFloor.getText() == null )
            return "";
        else
            return jTextFieldFloor.getText();
    }

    public void setCountry( List<Country> countries ){
        DefaultComboBoxModel model = new DefaultComboBoxModel();
        for ( Country country : countries ) {
            model.addElement( country );
        }
        model.setSelectedItem(null);
        jComboBoxCountry.setModel( model );
    }

    public Country getCountry() {
        DefaultComboBoxModel model = (DefaultComboBoxModel) jComboBoxCountry.getModel();
        return (Country) model.getSelectedItem();
    }

    public void setState( List<State> states ) {
        DefaultComboBoxModel model = new DefaultComboBoxModel();
        for ( State state : states ) {
            model.addElement( state );
        }
        model.setSelectedItem(null);
        jComboBoxState.setModel( model );
    }

    public State getState() {
        DefaultComboBoxModel model = (DefaultComboBoxModel) jComboBoxState.getModel();
        return (State) model.getSelectedItem();
    }

     public void setCity( List<City> cities ) {
        DefaultComboBoxModel model = new DefaultComboBoxModel();
        for ( City city : cities ) {
            model.addElement( city );
        }
        model.setSelectedItem(null);
        jComboBoxCity.setModel( model );
    }

    public City getCity() {
        DefaultComboBoxModel model = (DefaultComboBoxModel) jComboBoxCity.getModel();
        return (City) model.getSelectedItem();
    }

    public String getPassword() {
        return jTextFieldPassword.getText();
    }

    public String getConfirmedPassword() {
        return jTextFieldConfirmedPassword.getText();
    }

    public String getEmail() {
        return jTextFieldEmail.getText();
    }

    public void showError( int focusElement, String errorMessage, String titleMessageWindow ) {
        JOptionPane.showMessageDialog( this,
                errorMessage,
                titleMessageWindow,
                JOptionPane.ERROR_MESSAGE);
        switch (focusElement) {
            case FIRST_NAME:            jTextFieldFirstName.requestFocus(); break;
            case LAST_NAME:             jTextFieldLastName.requestFocus(); break;
            case GENRE:                 jComboBoxGenre.requestFocus(); break;
            case DOCUMENT:              jTextFieldDocument.requestFocus(); break;
            case DOCUMENT_TYPE:         jComboBoxDocumentType.requestFocus(); break;
            case BIRTH_DATE:            jFormattedTextFieldBirthDate.requestFocus(); break;
            case PASSWORD:              jTextFieldPassword.requestFocus(); break;
            case CONFIRMED_PASSWORD:    jTextFieldConfirmedPassword.requestFocus(); break;
            case EMAIL:                 jTextFieldEmail.requestFocus(); break;
        }
    }

    public void showNotification( String notifiactionMessage, String notificationMessageTitle ) {
        JOptionPane.showMessageDialog( this,
                notifiactionMessage,
                notificationMessageTitle,
                JOptionPane.INFORMATION_MESSAGE);
    }

    public void close() {
        setDefaultCloseOperation(DISPOSE_ON_CLOSE);
        setVisible(false);
    }

    public void enableState() {
        jComboBoxState.setEnabled(true);
    }

    public void enableCity() {
        jComboBoxCity.setEnabled(true);
    }

    public void disableState() {
        jComboBoxState.setEnabled(false);
    }

    public void disableCity() {
        jComboBoxCity.setEnabled(false);
    }

    public void enableStreetNumber() {
        jTextFieldStreetNumber.setEnabled( true );
    }

    public void disableStreetNumber() {
        jTextFieldStreetNumber.setText( "" );
        jTextFieldStreetNumber.setEnabled( false );
    }

    public void enableDepartment() {
        jTextFieldDepartment.setEnabled( true );
    }

    public void disableDepartment() {
        jTextFieldDepartment.setText( "" );
        jTextFieldDepartment.setEnabled( false );
    }

    public void enableBlock() {
        jTextFieldBlock.setEnabled( true );
    }

    public void disableBlock() {
        jTextFieldBlock.setText( "" );
        jTextFieldBlock.setEnabled( false );
    }

    public void enableFloor() {
        jTextFieldFloor.setEnabled( true );
    }

    public void disableFloor() {
        jTextFieldFloor.setText( "" );
        jTextFieldFloor.setEnabled( false );
    }

    public void addDocumentTypeChangeListener( ItemListener listener ) {
        jComboBoxDocumentType.addItemListener( listener );
    }

    public void removeDocumentTypeChangeListener( ItemListener listener ) {
        jComboBoxDocumentType.removeItemListener( listener );
    }

    public void addCountryChangeListener( ItemListener listener ) {
        jComboBoxCountry.addItemListener( listener );
    }

    public void removeCountryChangeListener( ItemListener listener ) {
        jComboBoxCountry.removeItemListener( listener );
    }

    public void addStateChangeListener( ItemListener listener ) {
        jComboBoxState.addItemListener( listener );
    }

    public void removeStateChangeListener( ItemListener listener ) {
        jComboBoxState.removeItemListener( listener );
    }

    public void addCityChangeListener( ItemListener listener ) {
        jComboBoxCity.addItemListener( listener );
    }

    public void removeCityChangeListener( ItemListener listener ) {
        jComboBoxCity.removeItemListener( listener );
    }

    public void addSaveListener( ActionListener listener ) {
        jButtonSave.addActionListener( listener );
    }

    public void removeSaveListener( ActionListener listener ) {
        jButtonSave.removeActionListener( listener );
    }

    public void addCancelListener( ActionListener listener ) {
        jButtonCancel.addActionListener( listener );
    }

    public void removeCancelListener( ActionListener listener ) {
        jButtonCancel.removeActionListener( listener );
    }

    public void addStreetDocumentListener( DocumentListener listener ) {
        jTextFieldStreet.getDocument().addDocumentListener( listener );
    }

    public void removeStreetDocumentListener( DocumentListener listener ) {
        jTextFieldStreet.getDocument().removeDocumentListener( listener );
    }

    public void addStreetNumberDocumentListener( DocumentListener listener ) {
        jTextFieldStreetNumber.getDocument().addDocumentListener( listener );
    }

    public void removeStreetNumberDocumentListener( DocumentListener listener ) {
        jTextFieldStreetNumber.getDocument().removeDocumentListener( listener );
    }

    public void addDepartmentDocumentListener( DocumentListener listener ) {
        jTextFieldDepartment.getDocument().addDocumentListener( listener );
    }

    public void removeDepartmentDocumentListener( DocumentListener listener ) {
        jTextFieldDepartment.getDocument().removeDocumentListener( listener );
    }

    public boolean showConfirmation( String notifiactionMessage ) {
        int confirm = JOptionPane.showConfirmDialog( this, notifiactionMessage, "Confirmación", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE );

        if (JOptionPane.YES_OPTION == confirm)
            return true;
        else
            return false;
    }

    public Component asWidget() {
        return this;
    }
}


